<?php
declare (strict_types=1);

namespace app\mall\model;

use app\mall\model\traits\EnableTrait;
use think\Model;

/**
 * @mixin Model
 * @property mixed level_flag
 * @property mixed id
 * @property mixed|string refresh_token
 * @property int|mixed refresh_token_time
 */
class MallUser extends MallBase
{

    use EnableTrait;

    public function level()
    {
        return $this->belongsTo(MallUserLevelSetting::class, 'level_flag', 'flag')
            ->cache('modelUserLevelBelongs' . $this->level_flag, 60);
    }

    public function getLevelTextAttr()
    {
        return $this->level()->value('name');
    }
}
